package com.zyf.search.controller;

import com.zyf.search.pojo.Article;
import com.zyf.search.service.impl.ArticleSearchServiceImpl;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/articleSearch")
public class ArticleSearchController {
    @Autowired
    ArticleSearchServiceImpl articleSearchService;
    @RequestMapping(value = "/add",method= RequestMethod.POST)
    public Result add(@RequestBody Article article){
        articleSearchService.add(article);
        return new Result(true, StatusCode.OK, "添加文章成功");
    }
    @RequestMapping(value = "/selectByContent",method= RequestMethod.GET)
    public Result selectByContent(String Content,int pageNum,int pageSize){
        List list=new ArrayList();
        list.add(articleSearchService.selectByName("content",Content,pageNum,pageSize));
        return new Result(true, StatusCode.OK, "查找文章成功",list);
    }
}
